﻿Imports OMANE.Common.UI
Imports PTIC_Util
Imports PTIC_GestionBDD
Imports System.Windows.Input
Imports Microsoft.Practices.Prism.Commands

Namespace ViewModels
    Public Class ViewModelVariable
        Inherits V2ViewModelTabSection

        Private _CorrespEntreeTable As Correspondance
        Private _TableBDD As tableBDD
        Public Sub New(ByVal CorrespEntreeTable As Correspondance)
            _CorrespEntreeTable = CorrespEntreeTable
            _TableBDD = _CorrespEntreeTable.traitement
            _TableBDD.CalculerValeursEntree(CorrespEntreeTable.description)
        End Sub


        Public ReadOnly Property CorrespEntreeTable As Correspondance
            Get
                Return _CorrespEntreeTable
            End Get
        End Property

        Private _RefreshValeursEntreeChamps As ICommand
        Public ReadOnly Property RefreshValeursEntreeChamps As ICommand
            Get
                If _RefreshValeursEntreeChamps Is Nothing Then
                    _RefreshValeursEntreeChamps = New DelegateCommand(Of Correspondance)(AddressOf cmdActualiserValeursEntreeChamps)
                End If
                Return _RefreshValeursEntreeChamps
            End Get
        End Property
        Private Sub cmdActualiserValeursEntreeChamps(ByVal variableConsultee As Correspondance)
            _TableBDD.CalculerValeursEntree(variableConsultee.description)
        End Sub

        'Public Sub ProcVisuVariable(ByVal VariableConsultee As Correspondance)
        '    Dim typeVar As String = VariableConsultee.chOutil.Format.typeAff.Name
        '    Dim valeursVar As DataTable = _TableBDD.getValeursEntree(VariableConsultee.description)
        'End Sub


        Private _Nom As String
        Public Property Nom As String
            Get
                Return _Nom
            End Get
            Set(ByVal value As String)
                OnPropertyChanging("Nom")
                Dim args As New PropertyChangeEventArgs(Of String)(_Nom, value)
                OnNomChange(args)
                _Nom = args.NewValue
                OnPropertyChanged("Nom")
            End Set
        End Property
        Protected Overridable Sub OnNomChange(ByVal args As PropertyChangeEventArgs(Of String))
            RaiseEvent NomChange(Me, args)
        End Sub
        Public Event NomChange As PropertyChangeEventHandler(Of String)


        Private _Format As String
        Public Property Format As String
            Get
                Return _Format
            End Get
            Set(ByVal value As String)
                OnPropertyChanging("Format")
                Dim args As New PropertyChangeEventArgs(Of String)(_Format, value)
                OnFormatChange(args)
                _Format = args.NewValue
                OnPropertyChanged("Format")
            End Set
        End Property
        Protected Overridable Sub OnFormatChange(ByVal args As PropertyChangeEventArgs(Of String))
            RaiseEvent FormatChange(Me, args)
        End Sub
        Public Event FormatChange As PropertyChangeEventHandler(Of String)


        Private _ValeursDistinctes As DataTable
        Public Property ValeursDistinctes As DataTable
            Get
                Return _ValeursDistinctes
            End Get
            Set(ByVal value As DataTable)
                OnPropertyChanging("ValeursDistinctes")
                Dim args As New PropertyChangeEventArgs(Of DataTable)(_ValeursDistinctes, value)
                OnValeursDistinctesChange(args)
                _ValeursDistinctes = args.NewValue
                OnPropertyChanged("ValeursDistinctes")
            End Set
        End Property
        Protected Overridable Sub OnValeursDistinctesChange(ByVal args As PropertyChangeEventArgs(Of DataTable))
            RaiseEvent ValeursDistinctesChange(Me, args)
        End Sub
        Public Event ValeursDistinctesChange As PropertyChangeEventHandler(Of DataTable)


        Private _NombreValeursDictinctes As Integer
        Public Property NombreValeursDictinctes As Integer
            Get
                Return _NombreValeursDictinctes
            End Get
            Set(ByVal value As Integer)
                OnPropertyChanging("NombreValeursDictinctes")
                Dim args As New PropertyChangeEventArgs(Of Integer)(_NombreValeursDictinctes, value)
                OnNombreValeursDictinctesChange(args)
                _NombreValeursDictinctes = args.NewValue
                OnPropertyChanged("NombreValeursDictinctes")
            End Set
        End Property
        Protected Overridable Sub OnNombreValeursDictinctesChange(ByVal args As PropertyChangeEventArgs(Of Integer))
            RaiseEvent NombreValeursDictinctesChange(Me, args)
        End Sub
        Public Event NombreValeursDictinctesChange As PropertyChangeEventHandler(Of Integer)


    End Class
End Namespace